package com.cybertooth.dbconvenience.query.columns;

import org.junit.Test;

import static org.hamcrest.MatcherAssert.*;
import static org.hamcrest.Matchers.*;
import static org.mockito.Mockito.*;

/**
 * <p></p>
 *
 * @author dnelson
 */
public class WhenColumnWithAsIsCreated {

	@Test
	public void theExpectedToSqlOutputIsGenerated() {
		final String columnName = "column_name";
		final String fieldName = "columnName";
		ColumnNameTransformer t = mock(ColumnNameTransformer.class);
		when(t.transform(columnName)).thenReturn(fieldName);

		// not testing injection; use contructor
		ColumnWithAs c = new ColumnWithAs(t);
		c.column = new Column(columnName);
		assertThat(c.toSql().trim(), is(columnName + " AS " + fieldName));
	}
}
